package com.ruoyi.environment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.environment.domain.OpmEnvFirmWaste;
import com.ruoyi.environment.service.IOpmEnvFirmWasteService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 企业出渣Controller
 *
 * @author cjie
 * @date 2021-12-14
 */
@Api(tags = " 企业出渣")
@RestController
@RequestMapping("/opmEnvFirmWaste")
public class OpmEnvFirmWasteController extends BaseController {
    @Autowired
    private IOpmEnvFirmWasteService opmEnvFirmWasteService;

    /**
     * 查询企业出渣列表
     */
    @ApiOperation(value="查询企业出渣列表", notes="查询企业出渣列表")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:list")
    @GetMapping("/list")
    public TableDataInfo list(OpmEnvFirmWaste opmEnvFirmWaste) {
        startPage();
        List<OpmEnvFirmWaste> list = opmEnvFirmWasteService.selectOpmEnvFirmWasteList(opmEnvFirmWaste);
        return getDataTable(list);
    }

    /**
     * 导出企业出渣列表
     */
    @ApiOperation(value="导出企业出渣列表", notes="导出企业出渣列表")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:export")
    @Log(title = "企业出渣", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OpmEnvFirmWaste opmEnvFirmWaste) throws IOException {
        List<OpmEnvFirmWaste> list = opmEnvFirmWasteService.selectOpmEnvFirmWasteList(opmEnvFirmWaste);
        ExcelUtil<OpmEnvFirmWaste> util = new ExcelUtil<OpmEnvFirmWaste>(OpmEnvFirmWaste.class);
        util.exportExcel(response, list, "企业出渣数据");
    }
    /**
     * 获取企业出渣详细信息
     */
    @ApiOperation(value="获取企业出渣详细信息", notes="获取企业出渣详细信息")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(opmEnvFirmWasteService.selectOpmEnvFirmWasteById(id));
    }

    /**
     * 新增企业出渣
     */
    @ApiOperation(value="新增企业出渣", notes="新增企业出渣")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:add")
    @Log(title = "企业出渣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpmEnvFirmWaste opmEnvFirmWaste) {
        return toAjax(opmEnvFirmWasteService.insertOpmEnvFirmWaste(opmEnvFirmWaste));
    }

    /**
     * 修改企业出渣
     */
    @ApiOperation(value="修改企业出渣", notes="修改企业出渣")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:edit")
    @Log(title = "企业出渣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpmEnvFirmWaste opmEnvFirmWaste) {
        return toAjax(opmEnvFirmWasteService.updateOpmEnvFirmWaste(opmEnvFirmWaste));
    }

    /**
     * 删除企业出渣
     */
    @ApiOperation(value="删除企业出渣", notes="删除企业出渣")
    @ApiImplicitParam(name = "ids", value = "企业出渣ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "environment:opmEnvFirmWaste:remove")
    @Log(title = "企业出渣", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(opmEnvFirmWasteService.deleteOpmEnvFirmWasteByIds(ids));
    }
}
